package day0111;

import org.junit.Test;

public class NullPointerException {

	
	@Test
	public void test1() {
		//Teacher teacher;   //在方法中声明的局部变量必须手动初始化
		Teacher teacher = null;
		//The local variable teacher may not have been initialized
		// initialize  v   初始化
		System.out.println(teacher); // null  变量是null  直接打印不会报空指针异常
		
		//因为teacher时null ，相当于null.getAge();
		//只要是null.方法或者null.属性  
		System.out.println(teacher.id); // 空指针异常
		System.out.println(teacher.getAge());  //NullPointerException 空指针异常
		
	}
	
	@Test
	public void test2() {
		//默认new的是无参构造方法  系统提供
		Teacher teacher = new Teacher();
		
	}
}
